package com.cug.zfanspring.service;

import com.cug.zfanspring.bean.SynthesisData;
import com.cug.zfanspring.mapper.DeviceAlarmMapper;
import com.cug.zfanspring.mapper.IndexAlarmMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.Map;

@Service
@Transactional
public class SynthesisDataService {
    @Autowired
    DeviceAlarmMapper deviceAlarmMapper;
    @Autowired
    IndexAlarmMapper indexAlarmMapper;
    public SynthesisData getSynthesisData(){
        SynthesisData synthesisData=new SynthesisData();
        Map<String,Long> totalAlarms=new HashMap<>();
        Map<String,Long> repaired=new HashMap<>();
        Map<String,Long> unrepaired=new HashMap<>();
        Map<String,Long> deviceSum=new HashMap<>();
        Map<String,Long> onlineSum=new HashMap<>();
        Map<String,Long> offlineSum=new HashMap<>();

        String name1,name2,name3,name4,name5,name6;
        long number1,number2,number3,number4,number5,number6;
        name1="报警总数";
        name2="已处理总数";
        name3="未处理总数";
        name4="设备总数";
        name5="在线总数";
        name6="离线总数";
        number1=deviceAlarmMapper.getTotalAlarms();
        number2=deviceAlarmMapper.getRepaired();
        number3=deviceAlarmMapper.getunRepaired();
        number4=deviceAlarmMapper.getDeviceSum();
        number5=deviceAlarmMapper.getOnlineSum();
        number6=deviceAlarmMapper.getOfflineSum();

        totalAlarms.put(name1,number1);
        repaired.put(name2,number2);
        unrepaired.put(name3,number3);
        deviceSum.put(name4,number4);
        onlineSum.put(name5,number5);
        offlineSum.put(name6,number6);

        synthesisData.setDeviceSum(deviceSum);
        synthesisData.setOfflineSum(offlineSum);
        synthesisData.setOnlineSum(onlineSum);
        synthesisData.setRepaired(repaired);
        synthesisData.setTotalAlarms(totalAlarms);
        synthesisData.setUnrepaired(unrepaired);

        return synthesisData;
    }


}
